<?php

namespace App\Controller;

use App\Entity\Event;
use App\Form\ContactType;
use App\Interfaces\CmsInterface;
use App\Interfaces\MessageInterface;
use App\Service\Message;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/contact")
 * Class ContactController
 * @package App\Controller
 */
class ContactController extends AbstractController
{

	public function __construct() { }

    /**
     * @Route("/message")
     */
	public function showMessage(MessageInterface $message)
    {
        $message_string = $message->noteMessage('12', 'zhang san');
        return $this->render('contact/message.html.twig', compact('message_string'));
    }
	/**
	 * @Route("/cms")
	 */
	public function showService(CmsInterface $cms)
	{
		$articles = $cms->getList('de', 'dtt');
		return $this->render(
			'article/index.html.twig',
			['articles' => $articles]
		);
	}

	/**
     * @Route("/index", name="index")
     */
    public function index()
    {

        return $this->render('contact/index.html.twig', [
            'controller_name' => 'ContactController',
        ]);
    }

	/**
	 * @Route("/contact", name="contact")
	 */
    public function contact()
    {
    	$post = new Event();
    	$form = $this->createForm(ContactType::class, $post);
    	return $this->render(
    		'contact/contact.html.twig',
		    [
		    	'our_form' => $form->createView()
		    ]
	    );
    }

	/**
	 * @Route("/log")
	 * @param LoggerInterface $logger
	 * @throws \Exception
	 */
    public function log(LoggerInterface $logger)
    {
	     $logger->info('Log time show hello world' );
	     return new Response('ok', 201);
    }


}
